#ifndef RIBBONBAR_H
#define RIBBONBAR_H

#include <QToolButton>
#include <QWidget>
#include <QAction>
#include <QGroupBox>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QCheckBox>
#include <QTabWidget>
/*---------------------------------*/
//无边框界面ribbon类
//自定义工具栏按钮
class RibbonToolButton : public QToolButton
{
    Q_OBJECT
public:
    explicit RibbonToolButton();
};

class RibbonAction : public QAction
{
    Q_OBJECT
public:
    explicit RibbonAction(const QString &txt, const QString &toolTip,const QIcon& icn);
};




/*------------------------------------------------*/
//自定义工具栏按钮组
class RibbonToolButtonGroup : public QGroupBox
{
    Q_OBJECT
public:
    explicit RibbonToolButtonGroup(QGroupBox* parent = nullptr);
    void addToolBtn(RibbonToolButton* btn);
    void addToolBtn(QToolButton* btn);
    void addCheckBox(QCheckBox* check);

private:
    int nCnt            = 0;
    QGridLayout *layout = nullptr;
};




/*------------------------------------------------*/
//自定义ribbon工具栏
class RibbonToolBar : public QWidget
{
    Q_OBJECT
public:
    explicit RibbonToolBar(const QString &_name,QWidget *parent = nullptr);
    void addRibbonGroup(RibbonToolButtonGroup* gp);
    //添加最后一个stretch
    void setGroupEnd() {
        if(layout)
            layout->addStretch();
    }
    const QString getName() {
        return name;
    }

private:
    QList<RibbonToolButtonGroup*> lBtnGroup;
    QHBoxLayout* layout = nullptr;
    QString name = QString("");
};
/*------------------------------------------------*/
//总的Ribbon工具栏
class RibbonBar : public QTabWidget
{
    Q_OBJECT
public:
    explicit RibbonBar(QTabWidget *parent = nullptr);
    // 添加Ribbon工具栏类别
    void addRibbonToolBar(RibbonToolBar* rtb = nullptr);
    // 添加Ribbon工具栏下工具分组
    void addRibbonToolButtonGroup(RibbonToolBar *toolbar = nullptr,
                                  RibbonToolButtonGroup *group = nullptr);
    // 添加Ribbon工具栏--工具分组下按钮
    void addRibbonToolButton(RibbonToolBar *toolbar = nullptr,
                             RibbonToolButtonGroup *group = nullptr,
                             RibbonToolButton *ribbonToolButton = nullptr);

protected:
    //继承QWidget，则需要重写paintEvent函数，否则无法使用QSS
    //void paintEvent(QPaintEvent* e) Q_DECL_OVERRIDE;
private:
    QList<RibbonToolBar*> ltoolBtnBar;
    QHBoxLayout* layout = nullptr;
};



#endif // RIBBONBAR_H
